<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <title>楼盘图</title>
    <#include "../common/common.ftl"/>
</head>
<body>
<div class="layui-fluid">
    <form class="layui-form">
        <div class="layui-card">
            <div class="layui-card-header">
                安置项目：<span class="jmdf-color-red">${(azProject.projectName)!}</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
<#--
                保障类型：<span class="jmdf-color-red">${(contract.baoZhangType)!}</span>
-->
                <span style="position: absolute;right: 30px;">
                        <span class="layui-badge" style="background-color: ${colorMap['共享类房源']};">&nbsp;未选&nbsp;</span>
<#--                        <span class="layui-badge" style="background-color: ${colorMap['普选区房源']};">&nbsp;普选区房源&nbsp;</span>-->
                    <#--                        <span class="layui-badge" style="background-color: ${colorMap['期房区房源']};">&nbsp;期房区房源&nbsp;</span>-->
                    <#--                        <span class="layui-badge" style="background-color: ${colorMap['结余区房源']};">&nbsp;结余区房源&nbsp;</span>-->
                        <span class="layui-badge" style="background-color: ${colorMap['2']};">&nbsp;已选&nbsp;</span>
                </span>
            </div>
            <div class="layui-card-body" style="height: 150px;margin-top: -15px;">
                <div class="layui-form-item">
                    <div class="layui-form-mid">
                        <#if (buildNumList??)>
                        <#--定义第几次循环-->
                            <#assign index = 0 />
                            <#list buildNumList as buildNum>
                            <#--次数+1-->
                                <#assign index = index+1 />
                                <a class="layui-btn loadBuild" buildNum="${buildNum}">
                                    <i class="layui-icon layui-icon-home"></i>${(buildNum)!}幢</a>
                            <#--如果是第十二个则该行结束，index为0-->
                                <#if index%12 == 0>
                                    <#assign index = 0/>
                                    <br/><br/>
                                </#if>
                            </#list>
                        </#if>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <div class="layui-form-mid layui-col-md12">
                        <div id="buildInfo"></div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script src="/modules/business/house.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['jquery', 'form', 'layer', 'jmdf'], function () {
        var $ = layui.jquery, form = layui.form, layer = layui.layer, jmdf = layui.jmdf;
        $(".loadBuild").click(function () {
            var obj = $(this);
            loadHousePicture("${(contract.zsProject.id)!}", "${(azProject.id)!}", obj.attr("buildNum"));
            $(".loadBuild").removeClass("layui-btn-danger");
            obj.addClass("layui-btn-danger")
        });

        //查询楼盘图数据
        function loadHousePicture(zsProjectId, azProjectId, buildNum) {
            $.ajax({
                url: "loadHousePicture",
                type: "post",
                data: {
                    contractId: ${(contract.id)!},
                    zsProjectId: zsProjectId,
                    azProjectId: azProjectId,
                    buildNum: buildNum,
                    _time: new Date().getTime()
                },
                success: function (data) {
                    var pictureHtml = "";
                    var chooseLimitType = data.chooseLimitType;
                    if (chooseLimitType == 1) {
                        pictureHtml = getChooseHousePictureForLimit(data);
                    } else {
                        pictureHtml = getChooseHousePicture(data);
                    }
                    pictureHtml = getChooseHousePictureForLimit(data);

                    $("#buildInfo").html(pictureHtml);
                    $(".houseStyle").click(function () {
                        var obj = $(this);
                        var houseStatus = obj.attr("houseStatus");
                        //如果房源还未选并且还未审核通过
                        if (houseStatus != undefined && houseStatus == 1 && ${contract.chooseHouseStatus} == 1) {
                            jmdf.minForm("loadHouse?contractId=${(contract.id)!}&houseId=" + obj.attr("id"), "600px", "600px");
                        }
                    })
                }
            });
        }

        window.loadHousePicture = loadHousePicture;
    });
</script>
</body>
</html>